package org.lc.stk.model.course;

import java.util.List;

import org.hibernate.annotations.Comment;
import org.lc.stk.model.baseInfo.Department;
import org.lc.stk.model.baseInfo.MajorCengci;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

/**
 * 课程
 */
@Entity
@Table(name = "course")
@Comment("课程")
public class Course {

    public enum CourseState {
        ACTIVE(1),
        INACTIVE(2);
        private final int value;
        CourseState(int value) {
            this.value = value;
        }
        public int getValue() {
            return value;
        }
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;

    @Column
    @Comment("课程代码")
    private String code;

    @Column
    @Comment("课程名称")
    private String name;

    @Column
    @Comment("课程简称")
    private String shortName;

    @ManyToMany(mappedBy = "courses")
    private List<MajorCengci> majorCengcis;

    /**
     * 所属单位
     */
    @ManyToOne
    @Comment("所属单位")
    private Department department;

    @Column(columnDefinition = "int default 1")
    @Comment("状态，1.在用，2.停用")
    private Integer state;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getShortName() {
        return shortName;
    }

    public void setShortName(String shortName) {
        this.shortName = shortName;
    }


    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    public Integer getState() {
        return state;
    }

    public void setState(CourseState state) {
        this.state = state.getValue();
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public List<MajorCengci> getMajorCengcis() {
        return majorCengcis;
    }

    public void setMajorCengcis(List<MajorCengci> majorCengcis) {
        this.majorCengcis = majorCengcis;
    }




    
}
